<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/6/25
 * Time: 14:05
 */

namespace app\admin\controller;


use app\admin\logic\ArticleCateLogic;
use think\facade\Request;

class ArticleCate extends Base
{

    private $articleCateLogic;

    public function __construct()
    {
        parent::__construct();
        $this->articleCateLogic = new ArticleCateLogic();
    }

    public function index(){
        return $this->fetch();
    }

    public function ajaxIndex(){
        $where = Request::param();
        $articleList = $this->articleCateLogic->cateList($where, self::$nowPage);
        return json($articleList);
    }

    public function add(){
        $act = 'add';
        $id = Request::get('id');
        if ($id){
            $act = 'edit';
            $info = $this->articleCateLogic->cateInfo($id);
            $this->assign('info', $info['data']);
        }
        $this->assign('act', $act);
        return $this->fetch();
    }

    public function handle(){
        $data = Request::param();
        $res = $this->articleCateLogic->handle($data);
        return json($res);
    }

}